//
//  RemarkCell.m
//  KuWoCan
//
//  Created by hwd on 17/3/14.
//  Copyright © 2017年 hwd. All rights reserved.
//

#import "RemarkCell.h"

//备注单元格


@implementation RemarkCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])
    {
        [self setUpUI];
    }
    return self;
}

- (void)setUpUI
{
    UIView *bgView= [UIView new];
    bgView.backgroundColor = KwBgColor;
    [self addSubview:bgView];
    [bgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.right.equalTo(@0);
        make.height.equalTo(@10);
    }];
    
    UILabel *lab = [UILabel new];
    lab.text = @"订单备注";
    lab.textColor = [UIColor blackColor];
    lab.font = KwFont(14.0);
    [self addSubview:lab];
    [lab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@20);
        make.height.equalTo(@30);
        make.top.equalTo(bgView.mas_top).offset(20);
        make.width.equalTo(@70);
    }];
    
    _remarkTxtF = [UITextView new];
    _remarkTxtF.delegate = self;
    _remarkTxtF.font = [UIFont systemFontOfSize:15*screenW_6];
    //    _remarkTxtF.placeholder = @"请填写备注信息";
    [self addSubview:_remarkTxtF];
    [_remarkTxtF mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(@-10);
        make.left.equalTo(lab.mas_right).offset(25);
        make.top.equalTo(lab.mas_top);
        make.height.equalTo(@60);
    }];
    
    _placeLab = [[UILabel alloc]initWithFrame:CGRectMake(5*screenW_6,6*screenW_6, self.size.width-30*screenW_6, 20*screenW_6)];
    _placeLab.text = @"请填写备注信息";
    _placeLab.font = [UIFont systemFontOfSize:14*screenW_6];
    _placeLab.textColor = [UIColor lightGrayColor];
    [_remarkTxtF addSubview:_placeLab];
    if (_remarkTxtF.text.length > 0) {
        _placeLab.hidden = YES;
    }
    
    
}

-(void)textViewDidChange:(UITextView *)textView{
    if (textView.text.length>0) {
        _placeLab.hidden = YES;
    }else
    {
        _placeLab.hidden = NO;
    }
    
    if (_block) {
        _block(textView.text);
    }
}
//
//-(BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range
//replacementText:(NSString *)text
//{
//    //如果为回车则将键盘收起
//    if ([text isEqualToString:@"\n"]) {
//        [textView resignFirstResponder];
//        return NO;
//    }
//    return YES;
//}

@end
